#include "gifheader.h"

namespace WingGif {

GifHeader::GifHeader(QObject *parent) : GifBlock(parent) {}

QString GifHeader::signature() { return _signature; }

QString GifHeader::version() { return _version; }

GifLogicalScreenDescriptor *GifHeader::logicalScreenDescriptor() {
  return _logicalScreenDescriptor;
}

GifBlockKind GifHeader::kind() { return GifBlockKind::Other; }

bool GifHeader::read(QIODevice *stream,
                     QList<GifExtension *> controlExtensions) {
  Q_UNUSED(controlExtensions);
  _signature = stream->read(3);

  if (_signature != "GIF")
    return false;

  _version = stream->read(3);

  if (_version != "87a" && _version != "89a")
    return false;

  _logicalScreenDescriptor = new GifLogicalScreenDescriptor(stream, this);
  return true;
}

} // namespace WingGif
